home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************
- * test.c
- *
- * Driver function and example TileStackWindows
- * function to test out TileStackWindows.
- ****************************************************/
-
- #include "TileStackWindows.h"
-
- /*****************************************************
- * defines
- ****************************************************/
-
- #define NUM_TEST_WINDOWS 20
-
- /*****************************************************
- * prototypes
- ****************************************************/
-
- static Boolean StackWindows(Rect *enclosingRectPtr,
- WindowElementPtr p, int wCount);
-
- /*****************************************************
- * main
- ****************************************************/
- void main()
- {
- WindowPtr *p, windowPtrArray[NUM_TEST_WINDOWS];
- Rect theBounds;
- int i;
-
- theBounds.top = 50;
- theBounds.left = 50;
- theBounds.bottom = 200;
- theBounds.right = 200;
-
- p = windowPtrArray;
- i = NUM_TEST_WINDOWS;
- do {
- *p++ = NewWindow(0L, &theBounds, "\pTest",
- TRUE, 0, (WindowPtr) -1, TRUE, 0);
- OffsetRect(&theBounds, 3, 2);
- } while (--i);
-
- TileStackWindows(StackWindows);
- }
-
-
- /* window stacking variables used by StackWindows */
- #define WTitleHeight 18
- #define StaggerH 7
- #define StaggerV (WTitleHeight - 2)
- #define MinVertSize 200
- #define NextRowOffsetH 2
- #define NextRowOffsetV 4
-
- /*****************************************************
- * StackWindows -- example TileStackWindows proc
- *
- * Stack all the windows so you can see their
- * titles. Returns TRUE if we moved or sized at
- * least one window (if not then we don't need to
- * redraw the screen).
- ****************************************************/
- static Boolean StackWindows(enclosingRectPtr, p, wCount)
- Rect *enclosingRectPtr;
- WindowElementPtr p;
- int wCount;
- {
- WindowPtr w;
- Rect theBounds;
- Point upperLeft;
- int width;
- Boolean didOne, sizeChanged;
-
- theBounds = *enclosingRectPtr;
- theBounds.top += WTitleHeight;
- upperLeft = topLeft(theBounds);
- width = theBounds.right - theBounds.left;
-
- didOne = FALSE;
-
- /* this particular routine starts at the back
- * of the list and works it's way forward
- * (to the frontmost window)
- */
- p += wCount;
- do {
- p--;
- w = (WindowPtr) p->theWindowPtr;
- sizeChanged = MySizeWindow(w,
- theBounds.right - theBounds.left,
- theBounds.bottom - theBounds.top);
- didOne |= sizeChanged;
- didOne |= MyMoveWindow(w, theBounds.left,
- theBounds.top, sizeChanged);
- theBounds.left += StaggerH;
- theBounds.right += StaggerH;
- theBounds.top += StaggerV;
- if (theBounds.top >
- enclosingRectPtr->bottom - MinVertSize) {
- upperLeft.h += NextRowOffsetH;
- upperLeft.v += NextRowOffsetV;
- topLeft(theBounds) = upperLeft;
- theBounds.right = theBounds.left + width;
- }
- if (theBounds.right > enclosingRectPtr->right)
- theBounds.right = enclosingRectPtr->right;
- } while (--wCount);
-
- return (didOne);
- }
-